package com.aisoback.exception;


import com.aisoback.common.Code;

public class BusinessException extends RuntimeException {
    /**
     * 定义错误码
     */
    private final int code;

    /**
     * 自定义code
     *
     * @param code
     * @param message
     */
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    /**
     * 自定义message
     *
     * @param code
     * @param message
     */
    public BusinessException(Code code, String message) {
        super(message);
        this.code = code.getCode();
    }

    /**
     * 默认
     *
     * @param code
     */
    public BusinessException(Code code) {
        super(code.getMessage());
        this.code = code.getCode();
    }

    public int getCode() {
        return code;
    }
}
